﻿
using System;

namespace MathService
{
    public partial class Matrix
    {
        public static implicit operator MatrixComplex(Matrix M)
        {
            return new MatrixComplex(M.N, M.M, (i, j) => new Complex(M[i, j]));
        }

        public static explicit operator Matrix(MatrixComplex M)
        {
            return new Matrix(M.N, M.M, (i, j) => M[i, j].Abs);
        }

        public static explicit operator MatrixInt(Matrix M)
        {
            return new MatrixInt(M.N, M.M, (i, j) => (int)M[i, j]);
        }

        public MatrixInt Round()
        {
            return new MatrixInt(N, M, (i, j) => (int)Math.Round(this[i, j]));
        }

        public MatrixInt Round(int Digits)
        {
            return new MatrixInt(N, M, (i, j) => (int)Math.Round(this[i, j], Digits));
        }

        public MatrixInt Round(int Digits, MidpointRounding Rounding)
        {
            return new MatrixInt(N, M, (i, j) => (int)Math.Round(this[i, j], Digits, Rounding));
        }

        public static implicit operator Matrix(MatrixInt M)
        {
            return new Matrix(M.N, M.M, (i, j) => M[i, j]);
        }

    }
}
